package org.leviatan.dataharbour.core.model.impl;

import java.util.Map;

import org.leviatan.dataharbour.core.model.DataEntity;
import org.leviatan.dataharbour.core.model.HarbourRequest;

public class HarbourRequestImpl implements HarbourRequest {
	
	/* db id */
	private String id;
	
	private String senderId;
	private String actorId;
	private String taskId;
	private String taskName;
	private String processId;
	private String processName;
	private int processVersion;
	private String processInstanceId;
	
	/* <id,object> */
	private Map<String, DataEntity> dataEntityMap;
	
	public String toString() {
		String outPut = "\n[harbour-request]: \nid: " + this.getId() + 
			"sender id: " + this.getSenderId() + "\n";
		return outPut;
	}
	
	public HarbourRequestImpl() {
	}
	
	public HarbourRequestImpl(String id) {
		this.id = id;
	}
	
	public String getId() {
		return this.id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getProcessInstanceId() {
		return this.processInstanceId;
	}
	public void setProcessInstanceId(String processInstanceId) {
		this.processInstanceId = processInstanceId;
	}
	/**
	 * WFMS id
	 */
	public String getSenderId() {
		return this.senderId;
	}
	public void setSenderId(String senderId) {
		this.senderId = senderId;
	}
	
	public String getProcessId() {
		return this.processId;
	}
	public void setProcessId(String senderProcessId) {
		this.processId = senderProcessId;
	}
	
	public String getActorId() {
		return this.actorId;
	}
	public void setActorId(String actorId) {
		this.actorId = actorId;
	}
	public String getTaskId() {
		return this.taskId;
	}
	public void setTaskId(String taskId) {
		this.taskId = taskId;
	}
	public Map getDataEntityMap() {
		return this.dataEntityMap;
	}
	public void setDataEntityMap(Map<String, DataEntity> variableMap) {
		this.dataEntityMap = variableMap;
	}
	public String getTaskName() {
		return taskName;
	}
	public void setTaskName(String taskName) {
		this.taskName = taskName;
	}
	public String getProcessName() {
		return processName;
	}
	public void setProcessName(String processName) {
		this.processName = processName;
	}
	public int getProcessVersion() {
		return processVersion;
	}
	public void setProcessVersion(int processVersion) {
		this.processVersion = processVersion;
	}
	
	/*
	public String toXmlDataUnitsIncluded() {
		String xml = "";
		xml += "\n\t<request id=\"" + this.getId() + "\">";
		xml += "\n\t\t<sender id=\"" + this.getSenderId() + "\"/>";
		xml += "\n\t\t<actor id=\"" + this.getActorId() + "\"/>";
		xml += "\n\t\t<process-definition id=\"" + this.getProcessId() +
			"\" name=\"" + this.getProcessName() + 
			"\" version=\"" + this.getProcessVersion() + 
			"\"/>";
		xml += "\n\t\t<task id=\"" + this.getTaskId() +
			"\" name=\"" + this.getTaskName() +
			"\"/>";
		xml += "\n\t\t<process-instance id=\"" + this.getProcessInstanceId() + "\">";
		
		Object varName, varValue, varId;
		DataEntity dataEntity;
		for (Iterator j = this.getDataEntityMap().values().iterator(); j.hasNext(); ) {
			dataEntity = (DataEntity) j.next();
			varValue = dataEntity.getDataName();
			varName = dataEntity.getDataValue();
			varId = dataEntity.getId();
			xml += "\n\t\t\t<var>";
			xml += "\n\t\t\t\t<id><![CDATA[" +varId+"]]></id>";
			xml += "\n\t\t\t\t<name><![CDATA[" +varName+"]]></name>";
			xml += "\n\t\t\t\t<value><![CDATA["+varValue+"]]></value>";
			xml += "\n\t\t\t</var>";
		}
		xml += "\n\t\t</process-instance>";
		xml += "\n\t</request>";
		return xml;
	}
	*/
	
	

}
